package com.dxf.bigdata.D05_spark_again

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

import java.text.SimpleDateFormat
import java.util.{Calendar, Date}

object Filter {

  def main(args: Array[String]): Unit = {

    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("app")

    val sc = new SparkContext(sparkConf)

    //    val dataRDD = sc.makeRDD(List(1, 23, 4, 5, 6), 2)
    //    dataRDD.filter(_ % 2 != 0).collect().foreach(println)
    //
    //  }
    val calendar: Calendar = Calendar.getInstance()
    calendar.set(2015, 5, 17)
    val filterDate: Date = calendar.getTime
    val dataRDD = sc.textFile("./datas/apache.log")

    val value: RDD[String] = dataRDD.filter(
      line => {
        val words: Array[String] = line.split(" ")
        val times: String = words(3)
        times.startsWith("17/05/2015")
      }

    )
    value.collect().foreach(println)

  }
}